package com.ecoolex.ying.space.job.consumer;

import org.springframework.beans.factory.annotation.Autowired;

import com.ecoolex.framework.message.queue.Consumer;
import com.ecoolex.framework.message.queue.ConsumerComponent;
import com.ecoolex.framework.message.queue.Message;
import com.ecoolex.ying.space.core.manager.UserWorksCommentManager;
import com.ecoolex.ying.space.core.manager.UserWorksStatisticalManager;
import com.ecoolex.ying.space.job.core.JOBConstant;

@ConsumerComponent
public class UserLikeRecordConsumer {
	
	@Autowired
    private UserWorksCommentManager userWorksCommentManager;
    
    @Autowired
    private UserWorksStatisticalManager userWorksStatisticalManager;

	@Consumer(group = JOBConstant.MODULE_NAME, theme = "ying.space.user.like.user.works.create", describe = "点赞作品时统计数量")
	public void praseUserWorks(Message message) throws Exception {
		int worksId = Integer.valueOf(message.getContent());
		userWorksStatisticalManager.praseCount(worksId, this.getClass().getSimpleName());
	}
	
	@Consumer(group = JOBConstant.MODULE_NAME, theme = "ying.space.user.like.user.works.cancel", describe = "取消点赞作品时统计数量")
	public void cancelPraseUserWorks(Message message) throws Exception {
		int worksId = Integer.valueOf(message.getContent());
		userWorksStatisticalManager.cancelPraseCount(worksId, this.getClass().getSimpleName());
	}
	
	@Consumer(group = JOBConstant.MODULE_NAME, theme = "ying.space.user.like.user.works.comment.create", describe = "点赞评论时统计数量")
	public void praseUserWorksComment(Message message) throws Exception {
		int commentId = Integer.valueOf(message.getContent());
		userWorksCommentManager.praseComment(commentId, this.getClass().getSimpleName());
	}
	
	@Consumer(group = JOBConstant.MODULE_NAME, theme = "ying.space.user.like.user.works.comment.cancel", describe = "取消点赞评论时统计数量")
	public void cancelPraseUserWorksComment(Message message) throws Exception {
		int commentId = Integer.valueOf(message.getContent());
		userWorksCommentManager.cancelPraseComment(commentId, this.getClass().getSimpleName());
	}
}
